<?php

class CarregaCarrinho{
	function CarregaCarrinho(){
		@session_start();
	}
	
	function registraCookie($id,$qt){
		$_SESSION["id_".$id] = $qt;
	}
	
	function deletaCookie($id){
		unset($_SESSION["id_".$id]);
	}
	
	
	function deletaAllCookie(){
		foreach ($_SESSION as $name => $value) {
        	if(substr($name,0,3) == 'id_')
				unset($_SESSION["id_".substr($name,3)]);
    	}	
	}
	
	function quantidadeCookie(){
		$v = 0;
		foreach ($_SESSION as $name => $value) {
        	if(substr($name,0,3) == 'id_')
				$v += (int)$value;
    	}
		
		return $v;
	}
	
	function retornaCookie($id){
		foreach ($_SESSION as $name => $value) {
        	if($name == ('id_'.$id))
				return $_SESSION['id_'.$id];
    	}
	}
	
	function retornaCookieArray(){
		$array = NULL;
		foreach ($_SESSION as $name => $value) {
			if(substr($name,0,3) == 'id_')
				$array[] = substr($name,3);
    	}
		
		return $array;
	}
	
	
}
?>